package ${entity.packageName};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/${entity.tableName}")
public class ${entity.entityName}Controller {
    @Autowired
    ${entity.entityName}Service ${entity.tableName}Service;

    @GetMapping("/{id}")
    public ${entity.entityName} getOne(@PathVariable ${entity.columns[0].name} id){
        return ${entity.tableName}Service.getOne(id);
    }

    @GetMapping
    public List<${entity.entityName}> getListByBatch(){
        return ${entity.tableName}Service.getAll();
    }

    @PostMapping
    public void insert(${entity.entityName} ${entity.tableName}){
        ${entity.tableName}Service.insert(${entity.tableName});
    }

    @PutMapping
    public void update(${entity.entityName} ${entity.tableName}){
        ${entity.tableName}Service.update(${entity.tableName});
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable ${entity.columns[0].name} id){
        ${entity.tableName}Service.delOne(id);
    }

}